<div class="page-bar">
    <ul class="page-breadcrumb">
        <li>
            <a href="#">WMS</a>
        </li>
        <li>
            <i class="fa fa-circle"></i>
            <a href="#">Task</a>
        </li>
        <li>
            <i class="fa fa-circle"></i>
            <a href="#">Parcel Load Task</a>
        </li>
    </ul>
</div>
<div class="portlet light bordered" style="margin: 15px;">
    <div class="portlet-title">
        <div class="caption">
            <span class="caption-subject bold">Parcel Load Task List </span>
        </div>
    </div>
    <div class="portlet-body form form-horizontal">
        <form>
            <div class="row form-group">
                <div class="col-md-3">
                    <label>Task ID:</label>
                    <lt-tags-input ng-model="search.taskIds" placeholder="Enter Task ID" fill="TASK-" ng-keyup="keyUpSearch($event)"></lt-tags-input>
                </div>
                <div class="col-md-3">
                    <label>Entry ID:</label>
                    <input class="form-control" name="Entry ID" placeholder="Enter Entry ID" ng-model="search.entryId" ng-keyup="keyUpSearch($event)"/>
                </div>
                <div class="col-md-3">
                    <label>Customer</label>
                    <organization-auto-complete ng-model="search.customerId" name="customer" tag="Customer" allow-clear="true"></organization-auto-complete>
                </div>
                <div class="col-md-3">
                    <label>Carrier</label>
                    <organization-auto-complete ng-model="search.carrierId" name="carrier" tag="Carrier" allow-clear="true"></organization-auto-complete>
                </div>
            </div>
            <div class="row form-group">
                <div class="col-md-3">
                    <label>Location:</label>
                    <location-auto-complete  name="location" allow-clear="true" ng-model="search.locationId"></location-auto-complete>
                </div>
                <div class="col-md-3">
                    <label>Container NO:</label>
                    <input class="form-control" name="Container NO" placeholder="Enter Container NO" ng-model="search.containerNO" ng-keyup="keyUpSearch($event)"/>
                </div>
                <div class="col-md-3">
                    <label>Assignee</label>
                    <user-auto-complete name="assignee" allow-clear="true" ng-model="search.assigneeUserId"></user-auto-complete>

                </div>
                <div class="col-md-3">
                    <label>Status:</label>
                    <task-status-auto-complete allow-clear="true" ng-model="search.status"></task-status-auto-complete>
                </div>
            </div>
            <div class="row form-group">
                <div class="col-md-3">
                    <label>Priority:</label>
                    <task-priority-auto-complete allow-clear="true" ng-model="search.priority"></task-priority-auto-complete>
                </div>
            </div>
            <div class="form-group form-actions right" style="padding: 0px;">
                <waitting-btn type="submit" btn-class="btn blue" ng-click="searchTasks()"
                              value="'search'" is-loading="searching"></waitting-btn>
            </div>
        </form>
        <div ng-show="searching" class="text-center">
            <img src="assets/img/loading-spinner-grey.gif">
            <span>&nbsp;LOADING...</span>
        </div>
        <div class="table-scrollable">
            <table class="table table-striped table-bordered table-hover"  ng-show="!searching" >
                <thead>
                <tr>
                    <th>Task ID</th>
                    <th>Assignee</th>
                    <th>Status</th>
                    <th>Priority</th>
                    <th>Entry ID</th>
                    <th>Location</th>
                    <th>Container NO</th>
                    <th>Customer</th>
                    <th>Carrier</th>
                    <th>SLP</th>
                    <th width="15%">Tracking NO</th>
                    <th>Start Time</th>
                    <th>End Time</th>
                    <th>Description</th>
                    <th permission-check="{{'task::parcelLoadTask_write'}}">Actions</th>
                </tr>
                </thead>
                <tbody>
                <tr ng-repeat="task in tasks">
                    <td><a ng-href="{{'#/wms/task/load-task/parcel/' + task.id + '/view'}}" target="_blank">{{task.id}}</a></td>
                    <td>{{ task.assignee.firstName + ' ' + task.assignee.lastName}}</td>
                    <td>{{ task.status }}</td>
                    <td>{{ task.priority }}</td>
                    <td>{{ task.entryId }}</td>
                    <td>{{ task.locationName }}</td>
                    <td>{{ task.containerNO }}</td>
                    <td>{{ task.customerName }}</td>
                    <td>{{ task.carrierName }}</td>
                    <td>
                        <span ng-repeat="slp in task.steps[0].slpIds">{{slp}}&nbsp;</span>
                    </td>
                    <td>
                        <span ng-repeat="trackingNo in task.steps[0].trackingNos">{{trackingNo}} </span>
                    </td>
                    <td>{{ task.startTime | amDateFormat:'YYYY-MM-DD HH:mm'}}</td>
                    <td>{{ task.endTime | amDateFormat:'YYYY-MM-DD HH:mm' }}</td>
                    <td>{{ task.description }}</td>
                    <td permission-check="{{'task::parcelLoadTask_write'}}">
                        <a ng-click="deleteTask(task.id)"
                           ng-show="task.status == 'New'" title="Delete">Delete</a>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <pager total-count="paging.totalCount" current-page ="paging.pageNo" page-size="pageObj.pageSize"  load-content="loadContent(currentPage)"></pager>
    </div>
</div>